<template>
  <div>
    <div class="banner" @click="handleBannerClick">
      <img
        :src="bannerImg"
        class="banner-img"
      />
      <div class="banner-info">
        <div class="banner-title">{{sightName}}</div>
        <div class="banner-number"><span class="iconfont banner-icon">&#xe691;</span> {{gallaryImgs.length}}</div>
      </div>
    </div>
    <fade-animation>
      <!-- 这个banner-gallery会被slot标签接收并替换 -->
      <banner-gallery :imgs="gallaryImgs" v-show="showGrallery" @close="handleGralleryClose"></banner-gallery>
    </fade-animation>
  </div>
</template>

<script>
import BannerGallery from 'common/gallery/Gallery'
import FadeAnimation from 'common/fade/FadeAnimation'
export default {
  name: 'DetailBanner',
  props: {
    sightName: String,
    bannerImg: String,
    gallaryImgs: Array
  },
  data () {
    return {
      showGrallery: false
      // imgs: ['http://img5.imgtn.bdimg.com/it/u=3040475312,405616599&fm=26&gp=0.jpg', 'http://img3.imgtn.bdimg.com/it/u=1498645152,753827595&fm=26&gp=0.jpg']
    }
  },
  components: {
    BannerGallery,
    FadeAnimation
  },
  methods: {
    handleBannerClick () {
      this.showGrallery = true
    },
    handleGralleryClose () {
      this.showGrallery = false
    }
  }
}
</script>

<style lang="stylus" scoped>
.banner
  height: 0
  padding-bottom: 55%
  position: relative
  overflow: hidden
  .banner-img
    width: 100%
  .banner-info
    position: absolute
    left: 0
    right: 0
    bottom: 0
    line-height: .6rem
    background-image: linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, .8))
    color: #ffffff
    display: flex
    .banner-title
      flex: 1
      font-size: .32rem
      padding: 0 .2rem
    .banner-number
      padding: 0 .4rem
      height: .32rem
      line-height: .32rem
      font-size: .24rem
      border-radius: .2rem
      background-color: rgba(0, 0, 0, .8)
      margin-top: .14rem
      .banner-icon
        font-size: .24rem
</style>
